package com.rerun.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.rerun.entity.BlackList;
import com.rerun.entity.YoyoPark;
import com.rerun.entity.vo.ParkListShowVo;
import com.rerun.mapper.BlackListMapper;
import com.rerun.service.IYoyoParkService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author dax.
 * @version v1.0
 * @since 2017/10/26 13:36
 */
@Service
public class IBlackListServiceImpl extends ServiceImpl<BlackListMapper, BlackList> implements com.rerun.service.IBlackListService {
    @Resource
    private BlackListMapper blackListMapper;
    @Resource
    private IYoyoParkService iYoyoParkService;

    @Override
    public BlackList selectByMemberIdAndParkId(String memberId, long parkId) {
        return blackListMapper.selectByMemberIdAndParkId(memberId, parkId);
    }

    @Override
    public Page<YoyoPark> selectPageByMemberId(Page<YoyoPark> page, String memberId) {
        List<String> ids = blackListMapper.selectPageByMemberId(page, memberId);
        if (CollectionUtils.isNotEmpty(ids)) {
            List<YoyoPark> parks=   iYoyoParkService.selectPageForBlackList(ids);
              page.setRecords(parks);
        }
        return page;
    }
}
